00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EXPORTAREA33_HPP_
00016 #define EXPORTAREA33_HPP_
00017
00018 #include <iostream>
00019 #include <string>
00020 #include <vector>
00021 #include <map>
00022
00023 #include "gridpack/parallel/communicator.hpp"
00024 #include "gridpack/component/data_collection.hpp"
00025 #include "gridpack/parser/dictionary.hpp"
00026 #include "gridpack/network/base_network.hpp"
00027 #include "gridpack/export/base_export.hpp"
00028
00029 namespace gridpack {
00030 namespace expnet {
00031
00032 template <class _network>
00033 class ExportArea33
00034 {
00035 public:
00036
00037
00038
00039
00040 explicit ExportArea33(boost::shared_ptr<_network> network) :
00041 p_network(network), p_comm(network->communicator())
00042 {
00043 }
00044
00045
00046
00047
00048 virtual ~ExportArea33(){}
00049
00050
00051
00052
00053
00054
00055
00056
00057 void writeAreaBlock(std::ofstream &fout)
00058 {
00059 BaseExport<_network> exprt(p_comm);
00060 int me = p_comm.rank();
00061
00062 int nbus = p_network->numBuses();
00063 gridpack::component::DataCollection *data = p_network->getNetworkData().get();
00064 if (me == 0) {
00065 fout << "0 / END TRANSFORMER DATA, BEGIN AREA DATA" << std::endl;
00066 int narea;
00067 data->getValue(AREA_TOTAL,&narea);
00068 int i, j;
00069 char buf[MAX_STRING_SIZE];
00070 for (i=0; i<narea; i++) {
00071 double rval;
00072 int ival;
00073 std::string sval;
00074 char *ptr;
00075 ptr = buf;
00076 data->getValue(AREAINTG_NUMBER,&ival,i);
00077 sprintf(ptr,"%d,",ival);
00078 ptr += strlen(ptr);
00079 data->getValue(AREAINTG_ISW,&ival,i);
00080 sprintf(ptr,"%d,",ival);
00081 ptr += strlen(ptr);
00082 rval = 0.0;
00083 data->getValue(AREAINTG_PDES,&rval,i);
00084 sprintf(ptr,"%f,",rval);
00085 ptr += strlen(ptr);
00086 rval = 10.0;
00087 data->getValue(AREAINTG_PTOL,&rval,i);
00088 sprintf(ptr,"%f,",rval);
00089 ptr += strlen(ptr);
00090 sval = "\' \'";
00091 data->getValue(AREAINTG_NAME,&sval,i);
00092 sprintf(ptr,"%s",sval.c_str());
00093 fout << buf << std::endl;
00094 }
00095 }
00096 }
00097
00098 private:
00099 boost::shared_ptr<_network> p_network;
00100
00101 gridpack::parallel::Communicator p_comm;
00102 };
00103
00104 }
00105 }
00106
00107 #endif